const webpack = require("webpack");
const autoprefixer = require("autoprefixer");
const path = require("path");

function resolve(dir) {
  return path.join(__dirname, dir);
}


module.exports = {
  pages: {
    city: {
      entry: './src/main.js',
      template: './public/index.html',
      title: '城市运行管理服务平台',
      filename: 'index.html',
    },
    discipline: {
      entry: './src/discipline-main.js',
      template: './public/discipline.html',
      title: '小店区城市运行管理服务平台',
      filename: 'discipline.html',
    }
  },
  // 路径配置别名
  chainWebpack: config => {
    config.resolve.alias
      .set("@", resolve("./src"))
      .set("@assets", resolve("./src/assets"))
      .set("@request", resolve("./src/request"))
      .set("@views", resolve("./src/views"))
      .set("@components", resolve("./src/components"));
  },
  publicPath: "./",
  productionSourceMap: false,
  filenameHashing: false,
  lintOnSave: false,

  //jq配置
  configureWebpack: {
    plugins: [
      new webpack.ProvidePlugin({
        $: "jquery",
        jQuery: "jquery",
        "windows.jQuery": "jquery"
      })
    ],
    //高德地图
    externals: {
      AMap: "AMap"
    }
  },
  devServer: {
    open: true,
    host: "0.0.0.0",
    port: 8084,
    https: false,
    hotOnly: false,
    proxy: {
      "/api": {
        // target: 'https://zhgl.tyzhcs.cn/api',
        target: 'http://26005vokn472.vicp.fun:50412',
        // target: 'http://220.194.189.135:8888/api',
        changeOrigin: true,
        pathRewrite: {
          "^/api": ""
        }
      },
      "/other": {
        target: 'https://dbapi.tyzhcs.cn/api',
        changeOrigin: true,
        pathRewrite: {
          "^/other": ""
        }
      },
      "/ljxq": {
        // target: 'http://192.168.3.50:83',
        target: 'http://221.204.12.174:9064/api',
        changeOrigin: true,
        pathRewrite: {
          "^/ljxq": ""
        }
      },
      "/ypsd": {
        // target: 'http://220.194.189.135:8888/api',
        target: 'http://26005vokn472.vicp.fun:50412',
        // target: 'http://221.204.12.174:9064/api',
        changeOrigin: true,
        pathRewrite: {
          "^/ypsd": ""
        }
      },
    }
  },
  //  rem单位适配
  css: {
    sourceMap: false,
    loaderOptions: {
      postcss: {
        plugins: [
          autoprefixer() //加前缀
        ]
      }
    }
  },

  // less
  pluginOptions: {
    "style-resources-loader": {
      preProcessor: "less"
    }
  }
};